<template>
  <div v-show="dialogValue" class="add-form f-c" style="overflow:auto;">
    <div class="header">
      <div class="title" style="margin: 0">
        基本信息
      </div>
      <el-button @click="onPageBack">返回</el-button>
    </div>
      <el-descriptions title="" :column="3">
          <el-descriptions-item label="项目名称">{{ currentDetail.projectName }}</el-descriptions-item>
          <el-descriptions-item label="会议类别">{{ currentDetail.meetingTypeName }}</el-descriptions-item>
          <el-descriptions-item label="项目资金">{{ currentDetail.pocket }}万元</el-descriptions-item>
          <el-descriptions-item label="项目主体单位">{{ currentDetail.investorName }}</el-descriptions-item>
          <el-descriptions-item label="联系人">{{ currentDetail.contacts }}</el-descriptions-item>
          <el-descriptions-item label="联系电话">{{ currentDetail.phone }}</el-descriptions-item>
          <el-descriptions-item label="项目联系人">{{ currentDetail.projectContacts }}</el-descriptions-item>
          <el-descriptions-item label="项目联系人电话">{{ currentDetail.projectPhone }}</el-descriptions-item>
          <el-descriptions-item label="建设地址">{{ currentDetail.address }}</el-descriptions-item>
      </el-descriptions>
      <el-descriptions title="" :column="1">
          <el-descriptions-item label="项目内容" :span="1">
              {{ currentDetail.projectContent }}
          </el-descriptions-item>
      </el-descriptions>
      <div class="header">
          <div class="title" style="margin-bottom: 0;margin-top: 10px">
              附件资料
          </div>
      </div>
      <el-descriptions title="" :column="3">
          <el-descriptions-item label="纸张">{{ currentDetail.paperName }}</el-descriptions-item>
          <el-descriptions-item label="页数">{{ currentDetail.pages }}</el-descriptions-item>
          <el-descriptions-item label="资料份数">{{ currentDetail.copies }}</el-descriptions-item>
          <el-descriptions-item label="节约资金（元）">{{ currentDetail.savingCapital }}</el-descriptions-item>
    
      </el-descriptions>
      <FileView :file-list="currentDetail.files || []" />
    <div class="header">
      <div class="title" style="margin-bottom: 0">
        会议信息
      </div>
    </div>
    <el-descriptions title="" :column="2">
      <el-descriptions-item label="会议时间">{{ meetingDetail.meetingStartTime }} - {{ meetingDetail.meetingEndTime }}</el-descriptions-item>
      <el-descriptions-item label="会议室">{{ meetingDetail.meetingName }}</el-descriptions-item>
    </el-descriptions>
    <slot />
  </div>
</template>

<script>
import { http } from '@/api'
import FileView from '@/components/File/view'
import {getName, Investor, MeetingType} from "@/dict";
export default {
  name: 'Detail',
  components: {
    FileView
  },
  data() {
    return {
      dialogValue: false,
      currentDetail: {},
      meetingDetail: {},
      enterpriseDetail: {},
      fileList: []
    }
  },
  created() {

  },
  methods: {
    open(item) {
      this.currentDetail = {}
      this.meetingDetail = {}
      this.enterpriseDetail = {}
      this.fileList = []

      this.meetingDetail = item
      if (item.enterpriseId) {
        http.enterpriseAccount.read(item.enterpriseId).then(res => {
          this.enterpriseDetail = res
        })
      }
    http.project_center.read({ id: item.id }).then(res => {
        this.currentDetail = {
            ...res.data,
            meetingTypeName: getName(res.data.meetingType, MeetingType),
            investorName: getName(res.data.investor, Investor),
        }
    })
      http.meetingRoom.list().then(res => {
        this.formList[1].options = res.data.map(el => {
          return {
            value: el.id,
            name: el.meetingName
          }
        })
      })
      this.dialogValue = true
    },
    onPageBack() {
      this.$emit('get-page')
      this.dialogValue = false
    },
    onSave() {
      const formData = {
        id: this.currentDetail.id,
        meetingId: this.ruleForm.meetingId
      }
      if (this.ruleForm.timeValue && this.ruleForm.timeValue.length) {
        formData.meetingStartTime = this.ruleForm.timeValue[0]
        formData.meetingEndTime = this.ruleForm.timeValue[1]
      }
      http.meeting_apply.updateMeeting({
        ...formData
      }).then(res => {
        this.$message.success(res.msg)
        this.onPageBack()
      })
    }
  }
}
</script>

<style scoped lang="scss">
.title {
    margin-top: 30px;
}
</style>
